/* initialize.c - initproc */

#include <i386.h>
#include <kernel.h>

extern	int		entry();        /* start of kernel image, use &start    */
extern	int		end();          /* end of kernel image, use &end        */

/************************************************************************/
/***				NOTE:				      ***/
/***								      ***/
/***   This is where the system begins after the C environment has    ***/
/***   been established.  Interrupts are initially DISABLED.  The     ***/
/***   interrupt table has been initialized with a default handler    ***/
/***								      ***/
/***								      ***/
/************************************************************************/

/*------------------------------------------------------------------------
 *  The init process, this is where it all begins...
 *------------------------------------------------------------------------
 */

initproc()				/* The beginning */
{
	kprintf( "\n\nCPSC 415, 2010\n Xeros 1.1\nLocated at: %x to %x\n", &entry, &end );

	/* Initialize mem manager */
	kmeminit();

	/* Now create the first user process */
	create(root, ROOT_PROCESS_STACK_SIZE, "root");
	create(idleproc, 64, "idleproc");	
	
	if (!DISP_UT_FAKE_PROCESSES){
		/* Set up interrupts */
		contextInit();
	}
	
	/* Enter the dispatcher. It never leaves. */
	dispatch();

    /* This code should never be reached after you are done */
	for(;;); /* loop forever */
}
